home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_498 / wordsearch / src / reqglue.asm < prev    next >
Assembly Source File  |  1992-05-06  |  6KB  |  286 lines

  1.  
  2.     include "libraries/reqbase.i"
  3.  
  4.     xref    _ReqBase
  5.  
  6. GLUE    MACRO
  7.     XDEF    _\1
  8. _\1
  9.     ENDM
  10.  
  11. NEWSYS    MACRO
  12.     PEA    _LVO\1            ;4
  13.     BRA    JumpIt            ;2 to 4.
  14.     ENDM
  15.  
  16. STACKOFFSET    EQU    4
  17.  
  18.  
  19.  
  20. GLUE2    MACRO
  21.     XDEF    _\1
  22. _\1
  23.     MOVEM.L    D2-D4/A2-A3/A6,-(SP)
  24.     ENDM
  25.  
  26. NEWSYS2    MACRO
  27.     MOVE.L    _ReqBase,A6
  28.     JSR    _LVO\1(A6)
  29.     MOVEM.L    (SP)+,D2-D4/A2-A3/A6
  30.     RTS
  31.     ENDM
  32.  
  33. STACKOFFSET2    EQU    28
  34.  
  35.     SECTION blah,CODE
  36.  
  37.     GLUE    Center
  38.     MOVE.L    STACKOFFSET(SP),A0
  39.     MOVEM.L    STACKOFFSET+4(SP),D0-D1
  40.     NEWSYS    Center
  41.  
  42.     GLUE    SetSize
  43.     MOVEM.L    STACKOFFSET(SP),D0-D1
  44.     NEWSYS    SetSize
  45.  
  46.     GLUE2    SetLocation
  47.     MOVEM.L    STACKOFFSET2(SP),D0-D2
  48.     NEWSYS2    SetLocation
  49.  
  50.     GLUE2    ReadLocation
  51.     MOVEM.L    STACKOFFSET2(SP),D0-D2
  52.     NEWSYS2    ReadLocation
  53.  
  54.     GLUE2    ReqFormat
  55.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  56.     NEWSYS2    ReqFormat
  57.  
  58.     GLUE    FileRequester
  59.     MOVE.L    STACKOFFSET(SP),A0
  60.     NEWSYS    FileRequester
  61.  
  62.     GLUE    ColorRequester
  63.     MOVE.L    STACKOFFSET(SP),D0
  64.     NEWSYS    ColorRequester
  65.  
  66.     GLUE    ExtendedColorRequester
  67.     MOVE.L    STACKOFFSET(SP),A0
  68.     NEWSYS    ExtendedColorRequester
  69.  
  70.     GLUE2    DrawBox
  71.     MOVE.L    STACKOFFSET2(SP),A1
  72.     MOVEM.L    STACKOFFSET2+4(SP),D0-D3
  73.     NEWSYS2    DrawBox
  74.  
  75.     GLUE2    MakeButton
  76.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  77.     MOVEM.L    STACKOFFSET2+12(SP),D0-D2
  78.     NEWSYS2    MakeButton
  79.  
  80.     GLUE2    MakeScrollBar
  81.     MOVE.L    STACKOFFSET2(SP),A0
  82.     MOVEM.L    STACKOFFSET2+4(SP),D0-D3
  83.     NEWSYS2    MakeScrollBar
  84.  
  85.     GLUE    PurgeFiles
  86.     MOVE.L    STACKOFFSET(SP),A0
  87.     NEWSYS    PurgeFiles
  88.  
  89.     GLUE    GetFontHeightAndWidth
  90.     NEWSYS    GetFontHeightAndWidth
  91.  
  92.     GLUE    MakeGadget
  93.     MOVEM.L    STACKOFFSET(SP),A0-A1    ;Parameter are on the stack in the order A0,A1,D0,D1
  94.     MOVEM.L    STACKOFFSET+8(SP),D0-D1
  95.     NEWSYS    MakeGadget
  96.  
  97.     GLUE    MakeString
  98.     MOVEM.L    STACKOFFSET(SP),A0-A1
  99.     MOVEM.L    STACKOFFSET+8(SP),D0-D1
  100.     NEWSYS    MakeString
  101.  
  102.     GLUE    MakeProp
  103.     MOVE.L    STACKOFFSET(SP),A0
  104.     MOVEM.L    STACKOFFSET+4(SP),D0-D2
  105.     NEWSYS    MakeProp
  106.  
  107.     GLUE2    LinkGadget
  108.     MOVEM.L    STACKOFFSET2(SP),A0-A1/A3
  109.     MOVEM.L    STACKOFFSET2+12(SP),D0-D1
  110.     NEWSYS2    LinkGadget
  111.  
  112.     GLUE2    LinkStringGadget
  113.     MOVEM.L    STACKOFFSET2(SP),A0-A3
  114.     MOVEM.L    STACKOFFSET2+16(SP),D0-D3
  115.     NEWSYS2    LinkStringGadget
  116.  
  117.     GLUE2    LinkPropGadget
  118.     MOVEM.L    STACKOFFSET2(SP),A0/A3
  119.     MOVEM.L    STACKOFFSET2+8(SP),D0-D4
  120.     NEWSYS2    LinkPropGadget
  121.  
  122.     GLUE2    GetString
  123.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  124.     MOVEM.L    STACKOFFSET2+12(SP),D0-D1
  125.     NEWSYS2    GetString
  126.  
  127.     GLUE    RealTimeScroll
  128.     MOVE.L    STACKOFFSET(SP),A0
  129.     NEWSYS    RealTimeScroll
  130.  
  131.     GLUE    NewGetString
  132.     MOVE.L    STACKOFFSET(SP),A0
  133.     NEWSYS    NewGetString
  134.  
  135.     GLUE    TextRequest
  136.     MOVE.L    STACKOFFSET(SP),A0
  137.     NEWSYS    TextRequest
  138.  
  139.     GLUE    GetLong
  140.     MOVE.L    STACKOFFSET(SP),A0
  141.     NEWSYS    GetLong
  142.  
  143.     GLUE    RawKeyToAscii
  144.     MOVEM.L    STACKOFFSET(SP),D0-D1
  145.     MOVE.L    STACKOFFSET+8(SP),A0
  146.     NEWSYS    RawKeyToAscii
  147.  
  148.  
  149. ;         These  routines  are a little bit more work to write glue code for
  150. ; because  they  use  register  beyond  the  scratch  register  D0-D1/A0-A1.
  151. ; Therefore  these  registers  have  to be saved before values can be loaded
  152. ; into them.
  153.  
  154.  
  155.  
  156. ;         This  code was designed to minimize the overhead of the individual
  157. ; pieces of glue code for the individual routines.  With this 'helper' code,
  158. ; all  the  glue  code for each routine has to do is load the registers from
  159. ; the  stack  (no  way  to  avoid that), push the _LVO offset onto the stack
  160. ; (hard  to  avoid  doing  something like that) and then branch down to this
  161. ; routine.
  162.  
  163.     XDEF    JumpIt,StackCleanup    ;Make these visible to a debugger.
  164.  
  165. JumpIt
  166.     PEA    StackCleanup        ;Push the address of the code that restores A6.
  167.     MOVE.L    4(sp),-(sp)        ;Push the _LVO offset further down the stack
  168.     MOVE.L    A6,8(sp)        ;so that the old value of A6 can be stored
  169.                     ;above it.
  170.     MOVE.L    _ReqBase,A6
  171.     MOVE.L    D0,-(sp)
  172.     MOVE.L    A6,D0
  173.     ADD.L    D0,4(sp)        ;Add _ReqBase to the _LVO offset so when you go
  174.                     ;return, you'll branch to the routine.
  175.     MOVE.L    (sp)+,D0
  176.     RTS
  177. StackCleanup
  178.     MOVE.L    (sp)+,A6
  179.     RTS
  180.  
  181.  
  182.  
  183. ;;;;;         The  version  of this code for Aztec is really simple, since Aztec
  184. ;;;;; doesn't currently expect you to preserve A6.
  185. ;;;;
  186. ;;;;JumpIt
  187. ;;;;    MOVE.L    _ReqBase,A6
  188. ;;;;    MOVE.L    D0,-(sp)
  189. ;;;;    MOVE.L    A6,D0
  190. ;;;;    ADD.L    D0,4(sp)        ;Add _ReqBase to the _LVO offset so when you go
  191. ;;;;                    ;return, you'll branch to the routine.
  192. ;;;;    MOVE.L    (sp)+,D0
  193. ;;;;    RTS
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. SureText    DC.B    "  Ok  ",0
  202. CancelText    DC.B    "Cancel",0
  203. ResumeText    DC.B    "Resume",0
  204.  
  205. ;    even
  206.     CNOP 0,2
  207.  
  208.     GLUE    SimpleRequest
  209.     MOVE.L    STACKOFFSET(SP),A0
  210.     LEA    STACKOFFSET+4(SP),A1
  211.     BRA    SimpleRequest
  212.  
  213.     GLUE    TwoGadRequest
  214.     MOVE.L    STACKOFFSET(SP),A0
  215.     LEA    STACKOFFSET+4(SP),A1
  216.     BRA    TwoGadRequest
  217.  
  218.  
  219.  
  220. ;srRegs    REG    A2-A4/D2
  221.  
  222. ;----------------------------------------------------
  223.     xdef    TwoGadRequest
  224. TwoGadRequest:
  225. ;Bool=TwoGadRequest(String,Controls)
  226. ;                     A0      A1
  227.  
  228. ;    MOVEM.L    srRegs,-(sp)
  229.     MOVEM.L    A2-A4/D2,-(SP)
  230.  
  231.     LEA.L    SureText,A2
  232.     LEA.L    CancelText,A3
  233.     BRA.S    TheRequest
  234.  
  235.     xdef    SimpleRequest
  236. SimpleRequest:
  237.  
  238. ;SimpleRequest(Text,Controls)
  239. ;               A0    A1
  240. ; This is just a method of telling a user something. It just calls MultiRequest
  241. ; with no gadgets.
  242.  
  243. ;    MOVEM.L    srRegs,-(sp)
  244.     MOVEM.L    A2-A4/D2,-(SP)
  245.     SUBA.L    A2,A2
  246.     LEA.L    ResumeText,A3
  247.  
  248. TheRequest
  249.  
  250.     MOVE.L    _ReqBase,A6    ;Load A6 from the data segment _before_ tromping on A4.
  251.  
  252.     SUB.W    #TR_SIZEOF,SP        ;get some temporary storage.
  253.  
  254.     MOVE.L    SP,A4
  255.     MOVEQ    #TR_SIZEOF/2-1,D2    ;because the stack is almost never clear.
  256. 1$    CLR.W    (A4)+
  257.     DBF    D2,1$
  258.  
  259.     MOVE.L    A0,TR_Text(SP)
  260.     MOVE.L    A1,TR_Controls(SP)
  261.     MOVE.L    A2,TR_PositiveText(SP)
  262.     MOVE.L    A3,TR_NegativeText(SP)
  263.  
  264.     MOVE.W    #$FFFF,TR_KeyMask(SP)
  265.  
  266.     MOVE.L    SP,A0
  267.     JSR    _LVOTextRequest(A6)
  268.  
  269.     ADD.W    #TR_SIZEOF,SP
  270.  
  271. ;    MOVEM.L    (SP)+,srRegs
  272.     MOVEM.L    (sp)+,A2-A4/D2
  273.     RTS
  274.  
  275.     GLUE GetFontHandW
  276.     MOVE.L   _ReqBase,A6
  277.     JSR    _LVOGetFontHeightAndWidth(A6)
  278.     LSL.W    #4,D1
  279.     LSL.W    #4,D1
  280.     ANDI.W    #$FF,D0
  281.     OR.W    D1,D0
  282.     RTS
  283.  
  284.  
  285.     END
  286.